package com.business.leaf.core.segment.service.impl;

import com.business.leaf.core.segment.domain.aggregate.SegmentManager;
import com.business.leaf.core.segment.ex.LeafEx;
import com.business.leaf.core.segment.repo.mapper.LeafAllocMapper;
import com.business.leaf.core.segment.service.LeafService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName LeafServiceImpl
 * @Description TODO
 * @Author lgh
 * @Date 2020-04-09 11:09
 */
@Service
public class LeafServiceImpl implements LeafService {


    @Autowired
    SegmentManager segmentManager;

    @Autowired
    LeafAllocMapper leafAllocMapper;

    @Override
    public long getIdByTag(String tag){
        return segmentManager.getIdByTag(tag);
    }

    @Override
    public String insertLeafAlloc(String bizTag, long step, String description) {
        //插入叶节点
        if (leafAllocMapper.insertLeafAlloc(bizTag,step,description)<1){
            LeafEx.LEAF_INSERT_LEAF_FAIL.throwEx();
        }
        return "SUCCESS";
    }


}
